/**
 * @author        Nicolas Bottarini <nicolasbottarini@gmail.com>, 404 <http://www.proyecto404.com>
 * @version       $Rev: 3 $
 * @lastrevision  $Date: 2011-09-12 16:45:37 +0000 (Mon, 12 Sep 2011) $	 
 */
package com.proyecto404.core.util {
	import com.proyecto404.core.BaseObject;
	import com.proyecto404.core.Check;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	
	/**
	 * @static
	 */
	public class BitmapHelper extends BaseObject {
		public static function copyBitmap(bitmapToCopy:Bitmap):Bitmap {
			Check.argument.isNotNull(bitmapToCopy, "bitmapToCopy");
			
			return new Bitmap(bitmapToCopy.bitmapData);
		}
		
		public static function createBitmapFromDisplayObject(obj:DisplayObject):Bitmap {
			Check.argument.isNotNull(obj, "obj");
			
			var bmpd:BitmapData = new BitmapData(obj.width, obj.height, true, 0xff0000);
			bmpd.draw(obj);
			var bmp:Bitmap = new Bitmap(bmpd);
			bmp.smoothing = true;
			bmp.x = obj.x;
			bmp.y = obj.y;
			return bmp;
		}
	}
}